package cn.wk.controller;

import cn.wk.service.IVerifyCodeService;
import cn.wk.util.AjaxResult;
import cn.wk.dto.SendSmsDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;
    /**
     * 图片验证码
     * @return
     */
    @GetMapping("/imageCode/{key}")
    public AjaxResult imageCode(@PathVariable("key") String imageCodeKey){
        String base64Image = verifyCodeService.imageCode(imageCodeKey);
        return AjaxResult.me().setResultObj(base64Image);
    }

    /**
     * 发送手机验证码
     * @param sendSmsVo
     */
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody SendSmsDto sendSmsVo){
        verifyCodeService.sendSmsCode(sendSmsVo);
        return AjaxResult.me();
    }
}
